package stat;

public class LivesDerivedStat extends DerivedStat {

    private int hpCache;
    
    public LivesDerivedStat( StatType st , Stat...toCache) {
        super(st, toCache);
        if(toCache.length > 0)
            hpCache = getFromCache(StatType.HP);
    }
    
    public LivesDerivedStat(StatType st, int value, Stat... toCache) {
        super(st, value, toCache);
        if(toCache.length > 0)
            hpCache = getFromCache(StatType.HP);
    }

    /**
     * compute the new lives value if entity died
     */
    @Override
    protected void compute() {
        if(getFromCache(StatType.HP) <= 0 && hpCache > 0) {
            this.decrement();
        }
        hpCache = getFromCache(StatType.HP);
    }
    
    

}
